﻿using System.Collections.Generic;
using System.Linq;
using FlickrApi;
using PhotoRepository;
using PhotoRepository.Models;

namespace PhotoRepository
{
    public class FlickrPhotoRepository : IPhotoRepository
    {
        private IFlickrApiCaller flickrApiCaller;
        public FlickrPhotoRepository(IFlickrApiCaller flickrApiCaller)
        {
            this.flickrApiCaller = flickrApiCaller;
        }
        public IEnumerable<Album> GetAlbums()
        {
            var photoSets = flickrApiCaller.GetListOfPhotoSets();
            return photoSets.Select(photoSet => new Album
            {
                Id = photoSet.Id,
                Name = photoSet.Title,
                Description = photoSet.Description,
                AlbumCoverUrl = photoSet.CoverUrl,
                CountPhotos = photoSet.CountPhotos
            });
        }
        public IEnumerable<Photo> GetPhotoUrlsForAlbum(string albumId)
        {
            var photos = flickrApiCaller.GetListOfPhotosInPhotoSet(albumId);
            return photos.Select(photo => new Photo
            {
                Url = photo.Url,
                Title = photo.Title
            });
        }
        public IEnumerable<Photo> GetPhotoUrlsForTag(string tag)
        {
            throw new System.NotImplementedException();
        }
    }
}
